/*
 * @Author: 张久冬
 * @Date: 2021-12-19 21:25:13
 * @
# Description: 网络请求封装
 */
import jdrequest from './request'
import LocalCache from '@/utils/cache'

const JDRequest = new jdrequest({
  // showLoading: true,
  // baseURL: 'http://localhost:1203',
  // baseURL: 'http://152.136.185.210:5000',
  baseURL: '/api',
  interceptor: {
    requestInterceptor: (config) => {
      // 携带token的拦截
      const token = LocalCache.getCache('token')
      if (token) {
        config.headers.Authorization = `Bearer ${token}`
      }
      return config
    },
    requestInterceptorCatch: (err) => {
      return err
    },
    responseInterceptor: (config) => {
      // console.log('响应成功的拦截器', config)
      return config.data
    }
  }
})
export default JDRequest
